package com.ruoyi.project.bajiaostar.jbhWemenu.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.jbhWemenu.domain.JbhWemenu;
import com.ruoyi.project.bajiaostar.jbhWemenu.service.IJbhWemenuService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 网站菜单Controller
 * 
 * @author 写烧糊
 * @date 2024-07-18
 */
@Controller
@RequestMapping("/bajiaostar/jbhWemenu")
public class JbhWemenuController extends BaseController
{
    private String prefix = "bajiaostar/jbhWemenu";

    @Autowired
    private IJbhWemenuService jbhWemenuService;

    @RequiresPermissions("bajiaostar:jbhWemenu:view")
    @GetMapping()
    public String jbhWemenu()
    {
        return prefix + "/jbhWemenu";
    }

    /**
     * 查询网站菜单列表
     */
    @RequiresPermissions("bajiaostar:jbhWemenu:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JbhWemenu jbhWemenu)
    {
        startPage();
        List<JbhWemenu> list = jbhWemenuService.selectJbhWemenuList(jbhWemenu);
        return getDataTable(list);
    }

    /**
     * 导出网站菜单列表
     */
    @RequiresPermissions("bajiaostar:jbhWemenu:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JbhWemenu jbhWemenu)
    {
        List<JbhWemenu> list = jbhWemenuService.selectJbhWemenuList(jbhWemenu);
        ExcelUtil<JbhWemenu> util = new ExcelUtil<JbhWemenu>(JbhWemenu.class);
        return util.exportExcel(list, "jbhWemenu",null);
    }

    /**
     * 新增网站菜单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存网站菜单
     */
    @RequiresPermissions("bajiaostar:jbhWemenu:add")
    @Log(title = "网站菜单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JbhWemenu jbhWemenu)
    {
        return toAjax(jbhWemenuService.insertJbhWemenu(jbhWemenu));
    }

    /**
     * 修改网站菜单
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JbhWemenu jbhWemenu = jbhWemenuService.selectJbhWemenuById(id);
        mmap.put("jbhWemenu", jbhWemenu);
        return prefix + "/edit";
    }

    /**
     * 修改保存网站菜单
     */
    @RequiresPermissions("bajiaostar:jbhWemenu:edit")
    @Log(title = "网站菜单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JbhWemenu jbhWemenu)
    {
        return toAjax(jbhWemenuService.updateJbhWemenu(jbhWemenu));
    }

    /**
     * 删除网站菜单
     */
    @RequiresPermissions("bajiaostar:jbhWemenu:remove")
    @Log(title = "网站菜单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jbhWemenuService.deleteJbhWemenuByIds(ids));
    }
}
